//
//  HZJViewController.swift
//  HZJNewClassUseByStoryBoard
//
//  Created by HZJ on 17/1/9.
//  Copyright © 2017年 HZJ. All rights reserved.
//

import UIKit

/**
 * -从stroyBoard中加载时的顺序： 1 - required init?(coder aDecoder: NSCoder)； 2 - awakeFromNib()； 3 - viewDidLoad。
 * -从代码中加载时顺序：1 - init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?)； 2 - viewDidLoad。
 *
 * -建议尽量不要重写UIViewController子类的init方法，省的麻烦
 * -因viewDidLoad始终会调用，所以应将属性初始化（或加载某些控件）的方法写于其中
 *
 *
 * -HZJViewController在init时，会自动寻找并加载HZJViewController.xib，若无则找HZJView.xib，若无则不加载
 */

class HZJViewController: UIViewController {

    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.randomColor()
        print(self.view.frame)
        setUpUI()
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print(self.view.frame)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    func setUpUI() {
//        let btn = UIButton()
//        btn.frame = CGRectMake(100, 100, 100, 100)
//        btn.backgroundColor = UIColor.randomColor()
//        btn.titleLabel?.text = "代码"
//        self.view.addSubview(btn)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        
    }
    //MARK: - 要么不写，要么当如此写
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
//        fatalError("init(coder:) has not been implemented")
    }
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("asdfasfdasdf")
    }
    
}
